{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import gym\n",
    "import cv2\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CNN Preprocessing \n",
    "\n",
    "Preprocessing, stacking and CNN architecture are based on the [DQN-Paper](https://web.stanford.edu/class/psych209/Readings/MnihEtAlHassibis15NatureControlDeepRL.pdf)\n",
    "\n",
    "Preprocessing of the DQN CNN:\n",
    "- 1. grayscaling the image to a shape (1, 210, 160)\n",
    "- 2. Resizing the image to 110x84\n",
    "- 3. cropping the image to a shape of (1, 84, 84)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "env = gym.make(\"Pong-v0\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(210, 160, 3)\n"
     ]
    }
   ],
   "source": [
    "state = env.reset()\n",
    "print(state.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM4AAAD8CAYAAAA/rZtiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAOX0lEQVR4nO3dfYwc9X3H8fenNhiXB/HsInCKQSYqVK1DLIqEQLQ0AawqDpVIjSripCgHEkiJlEoxILWoUqSUhiClD0QgrEBFDbSEwB9OwbKSoEg1sU2MsWMMNnHgsHtOnApIeUjP/vaP+V2znHe59Xd2b2e3n5d02t3fzNx8R8eHefDMdxURmNmR+Y1BF2A2jBwcswQHxyzBwTFLcHDMEhwcs4S+BU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xGcst5fBydcuhc2p7Bh2crhp7DIFLIuJCqp5yN0u6bNAF9dGw/s3uAc4FlgD7gLvKeGp7Bh2crhp7NF1E7C2v+4HHqXb1nZqZDItazViaJiImIuJgRBwC7uPXh2Op7Rl0cDYCiyUtknQ0sIKq2cfQkHSspOOn3gMfB7bRuZnJsBipZizTzsOuofobQbU9KyTNk7SIqgPtD2f8hQ24ArIMeInqasbtg64nUf85VFdlnge2T20DcApVa+CXy+vJg671A7ZhDdXhy/9Q/R/4hk71Ux3a/GP5e70ALB10/V1uzz+XereWsJzRMv/tZXt2Ald3sw7fOWCWMOhDNbOh5OCYJTg4ZgkOjlmCg2OW4OCYJTg4ZgkOjlnC/wKhLjBuvkWsmwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(state)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Grayscaling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM4AAAD8CAYAAAA/rZtiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAOXUlEQVR4nO3df4wc9XnH8fenJiCXiwQXA0LGgEFOVKjaC7EoEgLR0iRgVXGoRGKrIm6KekYCKZFSKQakFlWKSNMQpKgtkRFWoKL8aB2C/3AaLCsNilQIhhwGYgy245jDlh2Tih/llNTm6R/zvWY57/nWz+zezm4/L+m0u9+ZuXlGx4f54ZlnFRGY2Yn5rX4XYDaIHByzBAfHLMHBMUtwcMwSHByzhJ4FR9I1knZK2iVpXa/WY9YP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2WzOTQTGMzVhuKYeXG1oOnVPb0+/gdNTYYwBcHhGXUPWUu1nSlf0uqIcG9W92D3AhMAYcAO4q46nt6XdwOmrs0XQRsb+8HgIeo9rVz9bMZFDUasbSNBFxMCKORsR7wL385nAstT39Ds4zwDJJSyWdDKyiavYxMCSdKumD0++BTwAvMnszk0ExVM1YZpyHXUf1N4Jqe1ZJOkXSUqoOtD+e8xc24ArICuAVqqsZt/e7nkT9F1BdlXkeeGl6G4APUbUGfrW8jva71uNsw0NUhy//Q/V/4Btnq5/q0OYfy9/rBWB5v+vvcHv+udS7vYTl7Jb5by/bsxO4tpN1+M4Bs4R+H6qZDSQHxyzBwTFLcHDMEhwcswQHxyzBwTFLcHDMEv4XEyAxNcsPr2sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gray = cv2.cvtColor(state, cv2.COLOR_RGB2GRAY)\n",
    "plt.imshow(gray, cmap=\"gray\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Resizing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM4AAAD7CAYAAAAiqKvaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAM3klEQVR4nO3dX4wd5XnH8e+DHWIDNn9r49ioGMkiQUgpyBCSVFUwiUopirmACooqlFryDWlIiJRAexH1DqQISKUKYUFSt7L4U4IKQihRZIiqXtTFBCsBHAcXIlhsMAiDrXgtsubpxZlV186u/zyzZ2d29f1Iq7PzznvOPBr7p/fM2dF5IjORdGJO6roAa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s_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(110, 84)\n"
     ]
    }
   ],
   "source": [
    "resized = cv2.resize(gray, (84,110))\n",
    "plt.imshow(resized, cmap=\"gray\")\n",
    "plt.show()\n",
    "print(resized.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Cropping the image\n",
    "\n",
    "Cropping the image to 84×84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD7CAYAAACscuKmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAANKklEQVR4nO3df+hd9X3H8edr+aHVzsS4RjIji0JIlYHRBadzjC7Wzbmi+6MdShllCP2n29QWWt3+KIX9YWFUi4yCaDsZzh+1tpVQ7EJiGYOR+iNZq0ZrtJlm2sR1JnYJ6NK+98c9sV+yb8z55n7v997r5/mAy73nc+7lfA6H1/dz7rnn+3mnqpD03vcr4+6ApIVh2KVGGHapEYZdaoRhlxph2KVGDBX2JFcmeT7JriQ3z1enJM2/nOjv7EkWAT8CrgD2AI8D11XVs/PXPUnzZfEQn70Y2FVVLwEkuR+4Bjhm2JctW1YrV64cYpOS3s2+ffs4cOBAZls3TNjPAl6ZsbwH+O13+8DKlSu57bbbhtikpHdz0003HXPdMN/ZZ/vr8f++EyT5ZJInkjxx4MCBITYnaRjDhH0PcPaM5dXAq0e/qarurKoNVbVh2bJlQ2xO0jCGCfvjwNok5yRZClwLPDI/3ZI03074O3tVHU7yF8B3gUXAV6vqmXnrmaR5NcwFOqrqO8B35qkvkkbIO+ikRhh2qRGGXWqEYZcaYdilRhh2qRFjC/vWrVvZunXruDYvNceRXW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3Ft6VbniY3ADtnLE/z3IJfBh6tqg8CFzDYr6k8PiOZ+7GqFuQBXAp8d8byLcAtC7X9EezPt4ErgOeBVV3bKuD5cfdtDvuwmkEANgKbgDC4aWPxbMdskh/AacCP6a5DzWifyuPDYJq3V4AVDP6HZRPwh8Mcn4U8jT/S+SOmdt66JGuAC4FtwJlV9RpA97xyfD2bs9uBzwK/6JbPYHrnFjwXeB34Wve15K4kpzKlx6dGMPfjQoY9s7RN3U8BSd4PfAO4sareHHd/TlSSjwD7qurJmc2zvHVajtFi4CLgK1V1IYPbsqfilH02w879OJuFDPse4OwZy8ect25SJVnCIOj3VtXDXfPeJKu69auAfePq3xxdBlydZDdwP4NT+dvpObfgBNoD7KnBzEowmF3pIqb3+Aw19+NsFjLsjwNru6uJSxlcbHhkAbc/lG7+vbuBnVX1pRmrHmEwBx9M0Vx8VXVLVa2uqjUMjsXWqvo4Uzq3YFX9BHglybqu6chciVN5fBjF3I8LfNHhKuBHwIvA34z7Isgc+/67DE6ZfgDs6B5XMfieuwV4oXteMe6+nsC+fQjY1L0+F/g+sAv4OnDSuPs3h/1YDzzRHaNvAadP8/EBvgA8BzwN/CNw0jDHxzvopEZ4B53UCMMuNcKwS40w7FIjDLvUCMMuNcKwS40w7FIj/g/1QvkjJvPxigAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(84, 84)\n"
     ]
    }
   ],
   "source": [
    "cropped = resized[18:102,:]\n",
    "plt.imshow(cropped, cmap=\"gray\")\n",
    "plt.show()\n",
    "print(cropped.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Stacking the for last screens"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(84, 84)\n",
      "(1, 84, 84)\n"
     ]
    }
   ],
   "source": [
    "print(cropped.shape)\n",
    "cropped = cropped.reshape((1,84,84))\n",
    "print(cropped.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(4, 84, 84)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stacked = np.vstack([cropped, cropped, cropped, cropped])\n",
    "stacked.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# adding new state \n",
    "new_state = np.ones((1,84,84))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(4, 84, 84)\n"
     ]
    }
   ],
   "source": [
    "added = stacked[:3,:,:]\n",
    "added = np.concatenate((new_state, added))\n",
    "print(added.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Building the CNN for the DQN\n",
    "\n",
    "Building the original CNN of the DQN Paper"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "import torch.optim as optim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# building the convolution layers for testing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "cnn_1 = nn.Conv2d(4, out_channels=32, kernel_size=8, stride=4)\n",
    "cnn_2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=4, stride=2)\n",
    "cnn_3 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [],
   "source": [
    "img = torch.from_numpy(stacked).float().unsqueeze(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shape first layer:  torch.Size([1, 32, 20, 20])\n",
      "shape second_layer:  torch.Size([1, 64, 9, 9])\n",
      "shape third_layer:  torch.Size([1, 64, 7, 7])\n"
     ]
    }
   ],
   "source": [
    "x = cnn_1(img)\n",
    "print(\"shape first layer: \", x.shape)\n",
    "x = cnn_2(x)\n",
    "print(\"shape second_layer: \", x.shape)\n",
    "x = cnn_3(x)\n",
    "print(\"shape third_layer: \", x.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input_shape: 3136\n"
     ]
    }
   ],
   "source": [
    "flattened_input = x.flatten()\n",
    "input_shape = x.flatten().shape[0]\n",
    "print(\"input_shape:\", input_shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [],
   "source": [
    "ff_1 = nn.Linear(input_shape, 512)\n",
    "ff_2 = nn.Linear(512, env.action_space.n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Building the final DQN class"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "class DQN(nn.Module):\n",
    "    def __init__(self, action_size, input_shape = (4,84,84)):\n",
    "        super(DQN, self).__init__()\n",
    "        self.input_shape = input_shape\n",
    "        self.action_size = action_size\n",
    "        self.cnn_1 = nn.Conv2d(4, out_channels=32, kernel_size=8, stride=4)\n",
    "        self.cnn_2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=4, stride=2)\n",
    "        self.cnn_3 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1)\n",
    "        \n",
    "        self.ff_1 = nn.Linear(self.calc_input_layer(), 512)\n",
    "        self.ff_2 = nn.Linear(512, action_size)\n",
    "        \n",
    "    def calc_input_layer(self):\n",
    "        x = torch.zeros(self.input_shape).unsqueeze(0)\n",
    "        x = self.cnn_1(x)\n",
    "        x = self.cnn_2(x)\n",
    "        x = self.cnn_3(x)\n",
    "        return x.flatten().shape[0]\n",
    "    \n",
    "    def forward(self, x):\n",
    "        \"\"\"\n",
    "        \n",
    "        \"\"\"\n",
    "        x = torch.relu(self.cnn_1(x))\n",
    "        x = torch.relu(self.cnn_2(x))\n",
    "        x = torch.relu(self.cnn_3(x))\n",
    "        x = x.flatten()\n",
    "        x = torch.relu(self.ff_1(x))\n",
    "        out = self.ff_2(x)\n",
    "        \n",
    "        return out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "dqn = DQN(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DQN(\n",
       "  (cnn_1): Conv2d(4, 32, kernel_size=(8, 8), stride=(4, 4))\n",
       "  (cnn_2): Conv2d(32, 64, kernel_size=(4, 4), stride=(2, 2))\n",
       "  (cnn_3): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1))\n",
       "  (ff_1): Linear(in_features=3136, out_features=512, bias=True)\n",
       "  (ff_2): Linear(in_features=512, out_features=4, bias=True)\n",
       ")"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dqn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([ 4.2489, -3.7532,  0.4237, -4.3808], grad_fn=<AddBackward0>)"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dqn(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "start_eps = 1\n",
    "end_eps = 0.5\n",
    "annhealing_frames = 1000\n",
    "max_frames = 10000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "eps = []\n",
    "for i in range(max_frames):\n",
    "    if i <= annhealing_frames:\n",
    "        eps.append(max(start_eps - (i*(1/annhealing_frames)), end_eps))\n",
    "    else:\n",
    "        eps.append(end_eps - end_eps*((i-annhealing_frames)/(max_frames-annhealing_frames)))\n",
    "        print()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f750f17ba50>]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXAc93nm8e+LmzgJEAMCGJAiAVGkKJLCMLQOy4ckWyJ1mARYyUbKZuOcqk3i1Gaz8cYqb2W9TqXspLZ2E2+8TlSON5vUxo7jYECKuixbUnzElkVheB/iJZJoAMTBGyDO+e0f03AgCASHODiYnudTNcXpnkbP22jyqeavu9825xwiIpL+slJdgIiIzA0FuohIQCjQRUQCQoEuIhIQCnQRkYDISdUXV1ZWuhUrVqTq60VE0tLbb7/d65wLTfVZygJ9xYoV7N69O1VfLyKSlszs9PU+05CLiEhAKNBFRAJCgS4iEhAKdBGRgFCgi4gExA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gT4n+9X/7MiE+e9Z7nqvdBtymeqB1TN7dPYC4v8XMwK8CSx1znUC+H9W+Ytdb9vT7XfyZ8B/BuL+9BLgonNu1J+eWP97Hj4OjD98PJ22uR7oAf6PP8z0VTMrIsD72TnnAf8dOAN0kthvbxPs/TxurvZr2H8/ef600i3Qk3oYdToxs2Lgn4Dfdc5dnm7RKea5aeYvOGb2JNDtnHt74uwpFnU3+CxttpnEEedG4CvOuQjQT+K/4teT9tvsjxtvIzFMUgsUAY9NsWiQ9vON3Ow2zmjb0y3Qk3lgddows1wSYf7/nHMt/uxzZlbjf14DdPvzr7ft6fQ7eQDYambvAt8gMezyZ8BiSzxcHN5b//UePp5O29wOtDvn3vSnv0Ui4IO8nz8OnHLO9TjnRoAW4IMEez+Pm6v92u6/nzx/WukW6Mk8sDot+Ges/xo47Jz7HxM+mvjA7U+SGFsfn/9L/tny+4BL/n/pXgEeNbNy/8joUX/eguOce9Y5V+ecW0Fi373mnPu3wOskHi4O79/mqR4+vhN4yr86YiWwisQJpAXHOdcFnDWz1f6sjwGHCPB+JjHUcp+ZFfp/z8e3ObD7eYI52a/+Z1fM7D7/d/hLE9Z1fak+qTCDkxCPk7gi5ATw2VTXM4vt+BCJ/0LtA/b4r8dJjB1+Fzjm/1nhL2/Al/3t3g9smrCuXwWO+69fSfW2Jbn9D/KvV7nUk/iHehz4RyDfn1/gTx/3P6+f8POf9X8XR0ni7H+Kt7UR2O3v61YSVzMEej8D/w04AhwA/o7ElSqB2s/A10mcIxghcUT9a3O5X4FN/u/vBPAXTDqxPu6z884AAAA2SURBVNVLt/6LiAREug25iIjIdSjQRUQCQoEuIhIQCnQRkYBQoIuIBIQCXUQkIBToIiIB8f8B8NKN3vBrCnsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(eps)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1.0,\n",
       " 0.999,\n",
       " 0.998,\n",
       " 0.997,\n",
       " 0.996,\n",
       " 0.995,\n",
       " 0.994,\n",
       " 0.993,\n",
       " 0.992,\n",
       " 0.991,\n",
       " 0.99,\n",
       " 0.989,\n",
       " 0.988,\n",
       " 0.987,\n",
       " 0.986,\n",
       " 0.985,\n",
       " 0.984,\n",
       " 0.983,\n",
       " 0.982,\n",
       " 0.981,\n",
       " 0.98,\n",
       " 0.979,\n",
       " 0.978,\n",
       " 0.977,\n",
       " 0.976,\n",
       " 0.975,\n",
       " 0.974,\n",
       " 0.973,\n",
       " 0.972,\n",
       " 0.971,\n",
       " 0.97,\n",
       " 0.969,\n",
       " 0.968,\n",
       " 0.967,\n",
       " 0.966,\n",
       " 0.965,\n",
       " 0.964,\n",
       " 0.963,\n",
       " 0.962,\n",
       " 0.961,\n",
       " 0.96,\n",
       " 0.959,\n",
       " 0.958,\n",
       " 0.957,\n",
       " 0.956,\n",
       " 0.955,\n",
       " 0.954,\n",
       " 0.953,\n",
       " 0.952,\n",
       " 0.951,\n",
       " 0.95,\n",
       " 0.949,\n",
       " 0.948,\n",
       " 0.947,\n",
       " 0.946,\n",
       " 0.945,\n",
       " 0.944,\n",
       " 0.943,\n",
       " 0.942,\n",
       " 0.941,\n",
       " 0.94,\n",
       " 0.9390000000000001,\n",
       " 0.938,\n",
       " 0.937,\n",
       " 0.9359999999999999,\n",
       " 0.935,\n",
       " 0.9339999999999999,\n",
       " 0.933,\n",
       " 0.9319999999999999,\n",
       " 0.931,\n",
       " 0.9299999999999999,\n",
       " 0.929,\n",
       " 0.9279999999999999,\n",
       " 0.927,\n",
       " 0.926,\n",
       " 0.925,\n",
       " 0.924,\n",
       " 0.923,\n",
       " 0.922,\n",
       " 0.921,\n",
       " 0.92,\n",
       " 0.919,\n",
       " 0.918,\n",
       " 0.917,\n",
       " 0.916,\n",
       " 0.915,\n",
       " 0.914,\n",
       " 0.913,\n",
       " 0.912,\n",
       " 0.911,\n",
       " 0.91,\n",
       " 0.909,\n",
       " 0.908,\n",
       " 0.907,\n",
       " 0.906,\n",
       " 0.905,\n",
       " 0.904,\n",
       " 0.903,\n",
       " 0.902,\n",
       " 0.901,\n",
       " 0.9,\n",
       " 0.899,\n",
       " 0.898,\n",
       " 0.897,\n",
       " 0.896,\n",
       " 0.895,\n",
       " 0.894,\n",
       " 0.893,\n",
       " 0.892,\n",
       " 0.891,\n",
       " 0.89,\n",
       " 0.889,\n",
       " 0.888,\n",
       " 0.887,\n",
       " 0.886,\n",
       " 0.885,\n",
       " 0.884,\n",
       " 0.883,\n",
       " 0.882,\n",
       " 0.881,\n",
       " 0.88,\n",
       " 0.879,\n",
       " 0.878,\n",
       " 0.877,\n",
       " 0.876,\n",
       " 0.875,\n",
       " 0.874,\n",
       " 0.873,\n",
       " 0.872,\n",
       " 0.871,\n",
       " 0.87,\n",
       " 0.869,\n",
       " 0.868,\n",
       " 0.867,\n",
       " 0.866,\n",
       " 0.865,\n",
       " 0.864,\n",
       " 0.863,\n",
       " 0.862,\n",
       " 0.861,\n",
       " 0.86,\n",
       " 0.859,\n",
       " 0.858,\n",
       " 0.857,\n",
       " 0.856,\n",
       " 0.855,\n",
       " 0.854,\n",
       " 0.853,\n",
       " 0.852,\n",
       " 0.851,\n",
       " 0.85,\n",
       " 0.849,\n",
       " 0.848,\n",
       " 0.847,\n",
       " 0.846,\n",
       " 0.845,\n",
       " 0.844,\n",
       " 0.843,\n",
       " 0.842,\n",
       " 0.841,\n",
       " 0.84,\n",
       " 0.839,\n",
       " 0.838,\n",
       " 0.837,\n",
       " 0.836,\n",
       " 0.835,\n",
       " 0.834,\n",
       " 0.833,\n",
       " 0.832,\n",
       " 0.831,\n",
       " 0.83,\n",
       " 0.829,\n",
       " 0.828,\n",
       " 0.827,\n",
       " 0.826,\n",
       " 0.825,\n",
       " 0.8240000000000001,\n",
       " 0.823,\n",
       " 0.8220000000000001,\n",
       " 0.821,\n",
       " 0.8200000000000001,\n",
       " 0.819,\n",
       " 0.8180000000000001,\n",
       " 0.817,\n",
       " 0.8160000000000001,\n",
       " 0.815,\n",
       " 0.8140000000000001,\n",
       " 0.813,\n",
       " 0.812,\n",
       " 0.8109999999999999,\n",
       " 0.81,\n",
       " 0.8089999999999999,\n",
       " 0.808,\n",
       " 0.8069999999999999,\n",
       " 0.806,\n",
       " 0.8049999999999999,\n",
       " 0.804,\n",
       " 0.8029999999999999,\n",
       " 0.802,\n",
       " 0.8009999999999999,\n",
       " 0.8,\n",
       " 0.7989999999999999,\n",
       " 0.798,\n",
       " 0.7969999999999999,\n",
       " 0.796,\n",
       " 0.7949999999999999,\n",
       " 0.794,\n",
       " 0.7929999999999999,\n",
       " 0.792,\n",
       " 0.791,\n",
       " 0.79,\n",
       " 0.789,\n",
       " 0.788,\n",
       " 0.787,\n",
       " 0.786,\n",
       " 0.785,\n",
       " 0.784,\n",
       " 0.783,\n",
       " 0.782,\n",
       " 0.781,\n",
       " 0.78,\n",
       " 0.779,\n",
       " 0.778,\n",
       " 0.777,\n",
       " 0.776,\n",
       " 0.775,\n",
       " 0.774,\n",
       " 0.773,\n",
       " 0.772,\n",
       " 0.771,\n",
       " 0.77,\n",
       " 0.769,\n",
       " 0.768,\n",
       " 0.767,\n",
       " 0.766,\n",
       " 0.765,\n",
       " 0.764,\n",
       " 0.763,\n",
       " 0.762,\n",
       " 0.761,\n",
       " 0.76,\n",
       " 0.759,\n",
       " 0.758,\n",
       " 0.757,\n",
       " 0.756,\n",
       " 0.755,\n",
       " 0.754,\n",
       " 0.753,\n",
       " 0.752,\n",
       " 0.751,\n",
       " 0.75,\n",
       " 0.749,\n",
       " 0.748,\n",
       " 0.747,\n",
       " 0.746,\n",
       " 0.745,\n",
       " 0.744,\n",
       " 0.743,\n",
       " 0.742,\n",
       " 0.741,\n",
       " 0.74,\n",
       " 0.739,\n",
       " 0.738,\n",
       " 0.737,\n",
       " 0.736,\n",
       " 0.735,\n",
       " 0.734,\n",
       " 0.733,\n",
       " 0.732,\n",
       " 0.731,\n",
       " 0.73,\n",
       " 0.729,\n",
       " 0.728,\n",
       " 0.727,\n",
       " 0.726,\n",
       " 0.725,\n",
       " 0.724,\n",
       " 0.723,\n",
       " 0.722,\n",
       " 0.721,\n",
       " 0.72,\n",
       " 0.719,\n",
       " 0.718,\n",
       " 0.717,\n",
       " 0.716,\n",
       " 0.715,\n",
       " 0.714,\n",
       " 0.713,\n",
       " 0.712,\n",
       " 0.7110000000000001,\n",
       " 0.71,\n",
       " 0.7090000000000001,\n",
       " 0.708,\n",
       " 0.7070000000000001,\n",
       " 0.706,\n",
       " 0.7050000000000001,\n",
       " 0.704,\n",
       " 0.7030000000000001,\n",
       " 0.702,\n",
       " 0.7010000000000001,\n",
       " 0.7,\n",
       " 0.6990000000000001,\n",
       " 0.698,\n",
       " 0.6970000000000001,\n",
       " 0.696,\n",
       " 0.6950000000000001,\n",
       " 0.694,\n",
       " 0.6930000000000001,\n",
       " 0.692,\n",
       " 0.6910000000000001,\n",
       " 0.69,\n",
       " 0.6890000000000001,\n",
       " 0.688,\n",
       " 0.687,\n",
       " 0.6859999999999999,\n",
       " 0.685,\n",
       " 0.6839999999999999,\n",
       " 0.683,\n",
       " 0.6819999999999999,\n",
       " 0.681,\n",
       " 0.6799999999999999,\n",
       " 0.679,\n",
       " 0.6779999999999999,\n",
       " 0.677,\n",
       " 0.6759999999999999,\n",
       " 0.675,\n",
       " 0.6739999999999999,\n",
       " 0.673,\n",
       " 0.6719999999999999,\n",
       " 0.671,\n",
       " 0.6699999999999999,\n",
       " 0.669,\n",
       " 0.6679999999999999,\n",
       " 0.667,\n",
       " 0.6659999999999999,\n",
       " 0.665,\n",
       " 0.6639999999999999,\n",
       " 0.663,\n",
       " 0.6619999999999999,\n",
       " 0.661,\n",
       " 0.6599999999999999,\n",
       " 0.659,\n",
       " 0.6579999999999999,\n",
       " 0.657,\n",
       " 0.6559999999999999,\n",
       " 0.655,\n",
       " 0.6539999999999999,\n",
       " 0.653,\n",
       " 0.6519999999999999,\n",
       " 0.651,\n",
       " 0.6499999999999999,\n",
       " 0.649,\n",
       " 0.648,\n",
       " 0.647,\n",
       " 0.646,\n",
       " 0.645,\n",
       " 0.644,\n",
       " 0.643,\n",
       " 0.642,\n",
       " 0.641,\n",
       " 0.64,\n",
       " 0.639,\n",
       " 0.638,\n",
       " 0.637,\n",
       " 0.636,\n",
       " 0.635,\n",
       " 0.634,\n",
       " 0.633,\n",
       " 0.632,\n",
       " 0.631,\n",
       " 0.63,\n",
       " 0.629,\n",
       " 0.628,\n",
       " 0.627,\n",
       " 0.626,\n",
       " 0.625,\n",
       " 0.624,\n",
       " 0.623,\n",
       " 0.622,\n",
       " 0.621,\n",
       " 0.62,\n",
       " 0.619,\n",
       " 0.618,\n",
       " 0.617,\n",
       " 0.616,\n",
       " 0.615,\n",
       " 0.614,\n",
       " 0.613,\n",
       " 0.612,\n",
       " 0.611,\n",
       " 0.61,\n",
       " 0.609,\n",
       " 0.608,\n",
       " 0.607,\n",
       " 0.606,\n",
       " 0.605,\n",
       " 0.604,\n",
       " 0.603,\n",
       " 0.602,\n",
       " 0.601,\n",
       " 0.6,\n",
       " 0.599,\n",
       " 0.598,\n",
       " 0.597,\n",
       " 0.596,\n",
       " 0.595,\n",
       " 0.594,\n",
       " 0.593,\n",
       " 0.592,\n",
       " 0.591,\n",
       " 0.59,\n",
       " 0.589,\n",
       " 0.588,\n",
       " 0.587,\n",
       " 0.586,\n",
       " 0.585,\n",
       " 0.584,\n",
       " 0.583,\n",
       " 0.5820000000000001,\n",
       " 0.581,\n",
       " 0.5800000000000001,\n",
       " 0.579,\n",
       " 0.5780000000000001,\n",
       " 0.577,\n",
       " 0.5760000000000001,\n",
       " 0.575,\n",
       " 0.5740000000000001,\n",
       " 0.573,\n",
       " 0.5720000000000001,\n",
       " 0.571,\n",
       " 0.5700000000000001,\n",
       " 0.569,\n",
       " 0.5680000000000001,\n",
       " 0.567,\n",
       " 0.5660000000000001,\n",
       " 0.565,\n",
       " 0.5640000000000001,\n",
       " 0.563,\n",
       " 0.562,\n",
       " 0.5609999999999999,\n",
       " 0.56,\n",
       " 0.5589999999999999,\n",
       " 0.558,\n",
       " 0.5569999999999999,\n",
       " 0.556,\n",
       " 0.5549999999999999,\n",
       " 0.554,\n",
       " 0.5529999999999999,\n",
       " 0.552,\n",
       " 0.5509999999999999,\n",
       " 0.55,\n",
       " 0.5489999999999999,\n",
       " 0.548,\n",
       " 0.5469999999999999,\n",
       " 0.546,\n",
       " 0.5449999999999999,\n",
       " 0.544,\n",
       " 0.5429999999999999,\n",
       " 0.542,\n",
       " 0.5409999999999999,\n",
       " 0.54,\n",
       " 0.5389999999999999,\n",
       " 0.538,\n",
       " 0.5369999999999999,\n",
       " 0.536,\n",
       " 0.5349999999999999,\n",
       " 0.534,\n",
       " 0.5329999999999999,\n",
       " 0.532,\n",
       " 0.5309999999999999,\n",
       " 0.53,\n",
       " 0.5289999999999999,\n",
       " 0.528,\n",
       " 0.5269999999999999,\n",
       " 0.526,\n",
       " 0.5249999999999999,\n",
       " 0.524,\n",
       " 0.5229999999999999,\n",
       " 0.522,\n",
       " 0.5209999999999999,\n",
       " 0.52,\n",
       " 0.519,\n",
       " 0.518,\n",
       " 0.517,\n",
       " 0.516,\n",
       " 0.515,\n",
       " 0.514,\n",
       " 0.513,\n",
       " 0.512,\n",
       " 0.511,\n",
       " 0.51,\n",
       " 0.509,\n",
       " 0.508,\n",
       " 0.507,\n",
       " 0.506,\n",
       " 0.505,\n",
       " 0.504,\n",
       " 0.503,\n",
       " 0.502,\n",
       " 0.501,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " 0.5,\n",
       " ...]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.49994444444444447"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.5 - 0.5*(1/9000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
